package service;

import mapper.BusinessBuyTypeMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import pojo.BusinessBuyType;
import util.SqlSessionFactoryUtil;

import java.util.List;

public class BusinessBuyTypeService {
    private final SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtil.getSqlSessionFactory();

    /**
     * 使用多表查询来查询各年各月两种购票方式“线上购票”和“线下购票”的占比
     * 但是需要修改sql语句，所以如sql语句弄不了就暂时不要这个功能
     * @return
     */
    public List<BusinessBuyType> selectAll() {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        BusinessBuyTypeMapper mapper = sqlSession.getMapper(BusinessBuyTypeMapper.class);

        List<BusinessBuyType> businessBuyTypes = mapper.selectAll();

        sqlSession.close();
        return businessBuyTypes;
    }
}
